﻿<%@ Page Language="C#" %>

<%@ Import Namespace="wojilu" %>
<%@ Import Namespace="wojilu.View" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Domain" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Service" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>#{softtitle}</title>
<link href="#{path.css}ybb/css/baselist.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/all.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/formdiv.css?v=#{cssVersion}" rel="stylesheet" type="text/css"/>
<link href="#{path.css}ybb/css/prettyPhoto.css?v=#{cssVersion}" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="#{path.js}ybb/js/jquery.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/control.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/form.js?v=#{jsVersion}"></script>
<script type="text/javascript" language="JavaScript">
    var filemanage_filecheck_select_allno = "_{filemanage_filecheck_select_allno}";
    var filemanage_filecheck_select_max = "_{filemanage_filecheck_select_max}";
    var filemanage_js_album_select_err = "_{filemanage_js_album_select_err}";
	
    var fheight="#{fheight}";
    var loadurl="#{loadurl}";
	var ShowImage = function() {
            xOffset = 10;
            yOffset = 30;
            $("#imglist").find(".showpic").hover(function(e) {
                $("<img id='imgshow' src='" + this.id + "' height=\"100\"/>").appendTo("body");
                $("#imgshow").css("top", (e.pageY - xOffset) + "px").css("left", (e.pageX + yOffset) + "px").fadeIn("fast");
            }, function() {
                $("#imgshow").remove();
            });

            $("#imglist").find("span").mousemove(function(e) {
		$("#imgshow").css("top", (e.pageY - xOffset) + "px").css("left", (e.pageX + yOffset) + "px")
            });
        };

	$(document).ready(function(){
		var h = parseInt(fheight);
		$('#mainbodybottonauto').css({height:h-44});
		ShowImage();
	})

	function refile(){

		var albumlist=$('input:[name="albumlist"]').val();
		var albumiswidthlist=$('input:[name="albumiswidthlist"]').val();
		if(albumlist){

			filename=albumlist.substring(0,albumlist.length-1);
			iswidtharray=albumiswidthlist.substring(0,albumiswidthlist.length-1);
			parent.refile(filename,iswidtharray);
		}else{
			alert(filemanage_js_album_select_err);
			return false;
		}
	}

	function alselected(gid,imgpath,setype,iswidth){
		var gidstr="#"+gid;

		var maxselect=$('input:[name="maxselect"]').val();

		var albumlist=$('input:[name="albumlist"]').val();

		var albumiswidthlist=$('input:[name="albumiswidthlist"]').val();
		if (setype=='selected'){

			if (maxselect<1){
				alert(filemanage_filecheck_select_max);

				var htmlse='<input type="checkbox" id="'+gid+'" name="selectinfoid" value="'+imgpath+'" onclick="alselected(\''+gid+'\',this.value,\'selected\','+iswidth+');">';
				$(htmlse).replaceAll("#"+gid);
				return false;
			}

			var htmlse='<input type="checkbox" id="'+gid+'" name="selectinfoid" value="'+imgpath+'" onclick="alselected(\''+gid+'\',this.value,\'unde\','+iswidth+');" checked>';
			$(htmlse).replaceAll("#"+gid);

			var nowid=Number(maxselect)-1;
			$('input:[name="maxselect"]').val(nowid);

			var albumlist=albumlist+imgpath+'|';
			$('input:[name="albumlist"]').val(albumlist);

			var albumiswidthlist=albumiswidthlist+iswidth+'|';
			$('input:[name="albumiswidthlist"]').val(albumiswidthlist);

		}else{

			var htmlse='<input type="checkbox" id="'+gid+'" name="selectinfoid" value="'+imgpath+'" onclick="alselected(\''+gid+'\',this.value,\'selected\','+iswidth+');">';
			$(htmlse).replaceAll("#"+gid);

			var maxnowid=Number(maxselect)+1;
			$('input:[name="maxselect"]').val(maxnowid);

			var albumlist=albumlist.replace(imgpath+"|","");
			$('input:[name="albumlist"]').val(albumlist);

			var albumiswidthlist=albumiswidthlist.replace(iswidth+"|","");
			$('input:[name="albumiswidthlist"]').val(albumiswidthlist);
		}
	}
	document.oncontextmenu=new Function('event.returnValue=false;');
	document.onselectstart=new Function('event.returnValue=false;');
</script>
</head>
	
<body>
<input type="hidden" name="maxselect" value="#{maxselect}"/>
<input type="hidden" name="filepath" id="filepath" value="#{filepath}" />
<input type="hidden" name="albumlist" value=""/>
<input type="hidden" name="albumiswidthlist" value=""/>
<div id="mainbodybottonauto">
	<div class="filelist" id="imglist">
    <%var updirtype = Convert.ToInt32(v.data("updirtype")); %>
    <%if(updirtype == 1) {%>
	<div class="infolist" title="_{filemanage_view_updir}">
		<table border="0" style="border-collapse:collapse" width="100%" bordercolor="#FFFFFF" onclick="javascript:document.location='#{uploadurl}';">
			<tr>
				<td width="5%"></td>
				<td width="75%" id="left" class="padding-left3"><img src="#{path.img}ybb/images/fileicon/dir.png"> /#{dirlist}</td>
				<td width="20%" id="infotype">
					<table border="0" style="border-collapse:collapse" bordercolor="#FFFFFF">
						<tr>
							<td><a class="setedit3" id="center" href="#{uploadurl}" title="_{filemanage_view_updir}" hidefocus="true">_{filemanage_view_updir}</a></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</div>
	<%} %>
    <%var dt = v.data("dt") as System.Data.DataTable; %>
    <%if (dt.Rows.Count > 0)  { %>
    <%foreach(System.Data.DataRow row in dt.Rows) {%>
        <%
          var bottype = string.Empty;
          if (row["type"].ToString() == "1")
          {
              bottype = "dir";
          }    
          else
          {
              bottype = Utils.GetFileExtName(row["name"].ToString());
          }
        %>
	<div class="infolist gallery clearfix"  title="<%=row["loadurl2"] %>">
        <%if(bottype =="dir"){ %>
		<table border="0" style="border-collapse:collapse" width="100%" bordercolor="#FFFFFF" title="_{filemanage_view_opendir}" onclick="javascript:document.location='<%=row["loadurl"] %>';">
        <%} else if (bottype == "jpg" || bottype == "png" || bottype == "gif") { %>
		<table border="0" class="showpic" id="<%=sys.Path.Root %>#{filepath}#{dirlist}<%=row["name"] %>" style="border-collapse:collapse" width="100%" bordercolor="#FFFFFF">
		<%}else{ %>
		<table border="0"  style="border-collapse:collapse" width="100%" bordercolor="#FFFFFF">
		<%} %>
			<tr>
				<td width="5%">
                    <%if (bottype != "dir"){ %>
					<input type="checkbox" id="<%=row["fid"]%>" name="selectinfoid" value="#{picurl}<%=row["name"] %>" onclick="alselected('<%=row["fid"]%>',this.value,'selected',<%=row["iswidth"]%>);" />
					<%} %>
				</td>
				<td width="65%" id="left" class="padding-left3"><img src="#{path.img}ybb/images/fileicon/<%=bottype %>.png"> <%=row["name"].ToString().SplitString(".")[0] %></td>
				<td width="10%" id="right" class="padding-right3"><%if (bottype != "dir"){ %><%=row["size"] %><%} %></td>
				<td width="20%"><%=row["lastWriteTime"] %></td>
			</tr>
		</table>
	</div>
	<%} %>
	<%}else{ %>
	<div class="infolist">
		<table border="0" style="border-collapse:collapse" width="100%" bordercolor="#FFFFFF">
			<tr>
				<td align="center">_{list_nothing_title}</td>
			</tr>
		</table>
	</div>
	<%} %>
	</div>
</div>

<div id="downbotton" style="margin-top: 5px;">
	<div id="subbotton">
		<table border="0" width="100%">
			<tr id="bottonsubmit">
				<td id="right"><input type="submit" name="Submit" id="submitbotton" onclick="javascript:refile();" value="_{botton_add}" class="buttonface" title="_{botton_add}"/></td>
				<td id="left" class="padding-left5"><input type="reset" name="reset" onclick="javascript:parent.resetwindow();" id="release" value="_{botton_upfile_reset}" class="buttonface"  title="_{botton_upfile_reset}" /></td>
			</tr>
		</table>
	</div>
</div>
</body>

</html>